#ifndef CAMERAWINDOW_H
#define CAMERAWINDOW_H

#include <QWidget>
#include <QVBoxLayout>
#include "camera/QOpenCVWidget.h"
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <QPushButton>

class CameraWindow : public QWidget
{
    Q_OBJECT
    private:
        QOpenCVWidget *cvwidget;
        CvCapture *camera;
        IplImage *imageTaken;
        QImage img;
        int timerId;
        QPushButton *snapButton;
        QPushButton *cancelButton;
        QLabel *imagelabel;

    public:
        CameraWindow(CvCapture *cam, QWidget *parent=0);
        CameraWindow(QWidget *parent=0);
        QImage* cvImageToQImage(IplImage *image);
        ~CameraWindow();

    public slots:
        void stopTimer();
        void takePicture();
        void cancelPicture();

    signals:
        void imageCaptured( const QImage& image );
        void error( const QString& text );

    protected:
        void timerEvent(QTimerEvent*);


};

#endif // CAMERAWINDOW_H
